<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      width: 300px;
      height: 40px;
      border: 1px solid pink;
      text-align: center;
      line-height: 40px;
    }
  </style>
</head>

<body>
  <div></div>
  <script>
    // const div = document.querySelector('div')
    // // 得到日期对象
    // const date = new Date()
    // // 将日期对象 本地化
    // // 1. 完整的日期+时间  date.toLocaleString()      // 2022/4/1 09:41:21
    // // 2. 只有日期        date.toLocaleDateString()  // 2022/4/1
    // // 3. 只有时间        date.toLocaleTimeString()  // 16:57:40
    // div.innerHTML = date.toLocaleString()
    // setInterval(function () {
    //   const date = new Date()
    //   div.innerHTML = date.toLocaleString()

    // }, 1000)

    const date = new Date();

    console.log(date);
    console.log(date.toLocaleString());
    console.log(date.toLocaleDateString());
    console.log(date.toLocaleTimeString());

  </script>
</body>

</html>